/*$(function() {
	plupload_();	
});*/

function plupload_(){
	$("#uploader").pluploadQueue({
		/**上传插件初始化选用那种方式的优先级顺序，如果第一个初始化失败就走第二个，依次类推*/
		runtimes : 'gears,flash,silverlight,browserplus,html5,html4',
		/**上传服务器地址*/
		url : ctx + '/upload',
		multipart: true,  
		dragdrop:true,
		/**最大上传文件大小（格式100b, 10kb, 10mb, 1gb）*/
		max_file_size : '10mb',
		/**是否生成唯一的文件名，避免与服务器文件重名*/
		unique_names : true,
		urlstream_upload : true, 
		/**是否可以多次上传*/
		multiple_queues : false,  
		/**当上传文件大于服务器接收端文件大小限制的时候，可以分多次请求发给服务器，如果不需要从设置中移出*/
		/**chunk_size: '10mb',*/
		/**传参*/
		/**multipart_params:{'fid':getRequestParm('fid'),'note':(getRequestParm('note')==undefined?'':getRequestParm('note'))},*/
		multipart_params:{'fid':$('#fid').val(),'note':$('#note').val()},
		/**选择文件扩展名的过滤器,每个过滤规则中只有title和ext两项[{title:'', extensions:''}]*/
		filters : [
			{title : "文档", extensions : "xls,xlsx,doc,docx,pdf"},
			{title : "图片", extensions : "jpg,png,gif,jpeg"},
			{title : "压缩包", extensions : "rar,zip,war"},
			{title : "音、视频", extensions : "avi,mp4,mp3,wav,wmv"},
		],
		/**flash文件地址*/
		flash_swf_url : ctx + '/scripts/web/upload/plupload/js/plupload.flash.swf',
		silverlight_xap_url : ctx + '/scripts/web/upload/plupload/js/plupload.silverlight.xap'
	});
	var uploader = $('#uploader').pluploadQueue();
	/*uploader.bind('FileUploaded', function (uploader,file,responseObject) {
		var data = JSON.parse(responseObject.response);
		alert(data.result)
		if(!showMsg(data)){
			return;
		}
    });*/
    uploader.bind('Error', function (uploader,error) {
    	message('"' + error.file.name + '"' + "文件上传失败");
    });
    
    uploader.bind('UploadComplete', function (uploader,files) {
    	$("div.plupload_buttons").after('<a href="#" class="plupload_button plupload_add" id="uploader_next" style="display:inline-block">继续上传</a>');
    	$("#uploader_next").bind('click',function(){
    		plupload_();
    	})
    });
    /*
    uploader.bind('UploadComplete', function (uploader,files) {
		uploader.unbindAll();
		uploader.destroy();
   });*/
}